//
//  YQIncubatorProjectBottomView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/30.
//  Copyright © 2019 yuqin. All rights reserved.
//

#import "YQIncubatorProjectBottomView.h"

@implementation YQIncubatorProjectBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = WhiteColor;
        [self setupBottomView];
    }
    return self;
}

- (void)setupBottomView {
    NSArray *titleArr = @[@"首页",@"孵化"];
    NSArray *imgArr = @[@"homepage_nor",@"incubator_nor"];
    NSArray *selectArr = @[@"homepage_sel",@"incubator_sel"];
    for (NSInteger i = 0; i < 2; i++) {
        UIButton *bottomBtn = [YQViewFactory buttonWithTitle:titleArr[i] image:YQ_IMAGE(imgArr[i]) titleColor:UIColorFromRGB(0xa6a5a5) fontSize:FIT(12) userBold:NO target:self sel:@selector(switchCtlAction:)];
        [bottomBtn setImage:YQ_IMAGE(selectArr[i]) forState:UIControlStateSelected];
        [bottomBtn setTitleColor:UIColorFromRGB(0x5682E4) forState:UIControlStateSelected];
        bottomBtn.tag = 100+i;
        if (i == 0) {
            self.homePageBtn = bottomBtn;
            
        }else {
            self.incubatorBtn = bottomBtn;
        }
        [self addSubview:bottomBtn];
        bottomBtn.frame = CGRectMake(ScreenWidth/2.0*i, FIT(8), ScreenWidth/2.0, FIT(54));
        [bottomBtn setIconInTopWithSpacing:5];
    }
}

- (void)switchCtlAction:(UIButton *)sender {
    //单选
    if (self.homePageBtn.selected == YES) {
        self.homePageBtn.selected = YES;
        self.incubatorBtn.selected = NO;
    }else {
        self.homePageBtn.selected = NO;
        self.incubatorBtn.selected = YES;
    }
    if (self.SwitchCtlBlock) {
        self.SwitchCtlBlock(sender.tag);
    }
}

@end
